using System;
using System.Collections;
using System.Reflection;
using DataBroker.Dao;

namespace NorthwindDAO
{
	public class Customerdemographics : Entity
	{
		private String _CustomerTypeID;
		private String _CustomerDesc;
	
		///Default constructor
		public Customerdemographics ()
		{
		
		}

        /// <summary>
        /// Constructor for joins. 
		/// Available CHILD tables to join with:
		///    - Customercustomerdemo ( Customercustomerdemo_fk_customercustomerdemo )
        /// </summary>
        public Customerdemographics(bool Flat, params Entity[] entities)
            : this()
		{
			foreach(Entity entity in entities)
			{
				string[] entityParts = entity.GetType().ToString().Split('.');
				string entityName = entityParts[entityParts.Length - 1];
				PropertyInfo pf = GetType().GetProperty((entityName));
				if (pf != null)
				{
					pf.SetValue(this,new EntityCollection(entity), null);
				}
                entityName = entityName + "_"; ;
                pf = GetType().GetProperty((entityName));
                if (pf != null)
                {
                    pf.SetValue(this, entity, null);
                }
			}
			SetFlat(Flat);
		}
        public Customerdemographics(params Entity[] entities)
            : this(true, entities)
		{
		}
	
		[IsNotNullable]
		[IsPK]
		[MaxLength(10)]
		public String Customertypeid
		{
			get
			{
				return _CustomerTypeID;
			}
			set
			{
				_CustomerTypeID = value;
			}
		}
		[MaxLength(16)]
		public String Customerdesc
		{
			get
			{
				return _CustomerDesc;
			}
			set
			{
				_CustomerDesc = value;
			}
		}
	
        #region Customercustomerdemo 
        private EntityCollection _Customercustomerdemo;
        [NotInTable]
        [TypeContained(typeof(Customercustomerdemo),"Customercustomerdemo")]
        public EntityCollection Customercustomerdemo
        {
            get
            {
                return _Customercustomerdemo;
            }

            set
            {
                _Customercustomerdemo = value;
            }
        }
        private Customercustomerdemo _Customercustomerdemo_;
        [NotInTable]
        public Customercustomerdemo Customercustomerdemo_
        {
            get
            {
                return _Customercustomerdemo_;
            }

            set
            {
                _Customercustomerdemo_ = value;
            }
        }
        #endregion
        public override DBJoin GetJoin(string tableName)
        {
			if (string.Compare(tableName, "Customercustomerdemo", true) == 0)
			{
				ArrayList left = new ArrayList();
				ArrayList right = new ArrayList();
				left.Add(tableName + ".Customertypeid");
				right.Add(GetType().Name + ".Customertypeid");
				return new DBJoin(left, right, JoinTypeEnumeration.LEFT_OUTER);
			}
			return null;
		}
	}
}


